<template>
  <div id="app">
    <!-- <div id="nav">
      <router-link to="/">Home</router-link> |
      <router-link to="/about">About</router-link>
    </div>
    <router-view/> -->
    <el-container class="home-container">
      <el-header>
        <!-- <el-button @click="aa">{{ $t("message.clickMsg")}}</el-button> -->
         <div class="lang">
            <el-radio-group v-model="language" size="mini" @change="change">
                <el-radio label="zh" border>{{ $t("message.lang.zh") }}</el-radio>
                <el-radio label="en" border>{{ $t("message.lang.en") }}</el-radio>
            </el-radio-group>
        </div>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <Menu :message="message"></Menu>
        </el-aside>
        <el-main id="el-main">
          <transition name="fade-transform" mode="out-in">
            <!-- 天机key值可以 -->
           <router-view :key="key"/>
          </transition>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
import Menu from './components/Menu.vue'
export default {
  components:{
    Menu
  },
 
   data() {
        return {
            language: "en",
            message:this.$t('message.menu_list')
        };
    },
    // watch: {
    //     //侦听单选按钮的变化，从而进行切换语言
    //     language: function(val) {
    //         val === "zh" ? (this.$i18n.locale = "zh") : (this.$i18n.locale = "en");
    //     },
    //     deep:true
    // },
    created() {
      this.change()
    },
    computed:{
    key(){
      return this.$route.fullPath;
    }
   },
    methods: {
      aa(){
        console.log(this.message,"看看这是啥");
        console.log(this.language,"语言？");
      },
      change(){
        // console.log(this.language);
        this.language === "zh" ? (this.$i18n.locale = "zh") : (this.$i18n.locale = "en");
        // 变换之后 要重新进行 赋值 笨死了  - -！
        this.message = this.$t('message.menu_list')
        // window.sessionStorage.clear("language")
        window.sessionStorage.setItem('language', this.language)
      }
    },
}
</script>
<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50; 
}

#nav {
  padding: 30px;
}

#nav a {
  font-weight: bold;
  color: #2c3e50;
}

#nav a.router-link-exact-active {
  color: #42b983;
}
.home-container{
  height: 100%;
}
.lang{
  padding-top: 15px;
}
header{
  background: aquamarine;
}
</style>
